package com.guodefu.demo.controller;

import com.guodefu.demo.domain.Payment;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/testRedis")
public class TestRedisController {
    private StringRedisTemplate redisTemplate;

    public TestRedisController(StringRedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    @PostMapping("/save")
    public String testMongoDB(@RequestBody Payment payment) {
        ValueOperations<String, String> ops = redisTemplate.opsForValue();
        ops.set("testKey", "testValue");
        String value = ops.get("testKey");
        return value;
    }

}
